import axios from "axios";
import { Message } from 'element-ui';
import qs from 'qs';
import _ from '@/assets/utils';

const http = axios.create({
    baseURL: '/api',
    timeout: 60000,
    transformRequest: data => {
        if (_.isPlainObject(data)) data = qs.stringify(data);
        return data;
    }
});
http.interceptors.request.use(config => {
    return config;
});
http.interceptors.response.use(response => {
    return response.data;
}, reason => {
    Message.error('当前网络繁忙，请您稍后再试~');
    return Promise.reject(reason);
});
export default http;